/**
 * @file 模板加载插件
 * @author otakustay(otakustay@gmail.com)
 * @ignore
 */
define(
    function (require) {
        var template = require('etpl');
        template.addFilter(
            'indexOf',
            function (str, substr) {
                if (!str) {
                    return '';
                }
                return str.indexOf(substr);
            }
        );

        // 这一层为了可以在`paths`中设置别名，所以不能没有这个文件
        var tpl = require('ub-ria/tpl');

        // ub-ria-ui
        tpl.registerControl('ub-ria-ui/selectors/RichSelectorGroup');
        tpl.registerControl('ub-ria-ui/selectors/ToggleSelector');
        tpl.registerControl('ub-ria-ui/selectors/TableRichSelector');
        tpl.registerControl('ub-ria-ui/selectors/TreeRichSelector');
        tpl.registerControl('ub-ria-ui/colorPicker/ColorPicker');
        tpl.registerControl('ub-ria-ui/LightBox');
        tpl.registerControl('ub-ria-ui/TokenField');
        tpl.registerControl('ub-ria-ui/MediaPreview');

        tpl.registerControl('ui/uploader/File');
        tpl.registerControl('ui/uploader/FileInput');
        tpl.registerControl('ui/uploader/HttpRequest');
        tpl.registerControl('ui/uploader/XMLHttpRequest');
        tpl.registerControl('ui/uploader/L2XMLHttpRequest');
        tpl.registerControl('ui/uploader/IframeHttpRequest');
        tpl.registerControl('ui/uploader/ImagePreviewer');
        tpl.registerControl('ui/uploader/Progress');
        tpl.registerControl('ui/uploader/Uploader');

        // esui extension
        tpl.registerExtension('esui/extension/AutoTipLayer');

        // ub-ria-ui extension
        tpl.registerExtension('ub-ria-ui/AutoComplete');

        return tpl;
    }
);
